package com.abc.qq.view.tcp2;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 专门用来监听的线程
 */
public class ServerThread2 implements Runnable {
    private ServerSocket serverSocket;
    public ServerThread2(ServerSocket serverSocket) {
       this.serverSocket = serverSocket;
    }

    @Override
    public void run() {
        try {
            while (true) {
                Socket socket = serverSocket.accept();
                ServerChatThread thread = new ServerChatThread(socket);
                new Thread(thread).start();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
